﻿
@{
    ViewData["Title"] = "职位信息";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<div class="container-div white-bg">
    <div class="ibox-content">
        <form class="form-horizontal m" id="positionForm" autocomplete="off">
            <input type="hidden" id="id" name="id" value="@(ViewBag.Id)">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">职位名称：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="post_name" id="post_name" data-rule="required">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">职位编码：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="post_code" id="post_code">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">显示顺序：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="number" name="post_sort" value="1" id="post_sort" data-rule="required">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">

                    <label class="check-box checkbox-success">
                        <input type="radio" class="icheck" id="post_status" name="post_status" value="0" checked="" />
                        启动
                    </label>
                    <label class="check-box checkbox-success">
                        <input type="radio" class="icheck" id="post_status1" name="post_status" value="1" />
                        停用
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="remark" name="remark" class="form-control" type="text">
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="footerbar">
                <div class="col-sm-12 col-sm-offset-4">
                    <button class="btn btn-primary" type="submit">
                        <i class="fa fa-check"></i>
                        保存
                    </button>
                    <button class="btn btn-danger" type="button" onclick="cancel()">
                        <i class="fa fa-reply-all"></i>关闭
                    </button>
                </div>
            </div>
        </form>

    </div>
</div>
@section scripts{ 
    <script type="text/javascript">
        $(function () {
            $('#positionForm').validator({
                stopOnError: false,
                timely: 2,
                theme: "yellow_right",
                valid: function (form) {
                    //console.log(form);
                    jutils.ajaxPost("/admin/position/SaveData", $(form).serialize(), function (res) {
                        if (res.status) {
                            cancel();
                        }
                    });
                },
            });
            loadModel();
        });
        function loadModel() {
            let id = $('#id').val();
            if (jutils.emptyId(id)) {
                return;
            }
            jutils.ajaxGet('/admin/position/getmodel', { id: id }, function (res) {
                // console.log(res);
                if (res.status) {
                    let model = res.data.model;
                    $('#positionForm').initFormData(model);
                }
            });
        }


        function cancel() {
            jutils.closeDialog();
        }

    </script>
}